<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
%>
<html>
    <head>
        <title>Log.jsp</title>
        <link href="<%=path%>/bootstrap/css/bootstrap.css" rel="stylesheet">
        <script src="<%=path%>/jquery/jquery-3.3.1.js"></script>
        <script src="<%=path%>/jquery/jquery.cookie.js"></script>
        <script src="<%=path%>/bootstrap/js/bootstrap.js"></script>
    </head>
    <body>

        <div class="container">

            <table class="table">
                <thead>
                    <tr>
                        <th>序号</th>
                        <th>用户Id</th>
                        <th>用户姓名</th>
                        <th>用户电话</th>
                        <th>用户邮箱</th>
                        <th>用户地址</th>
                        <th>物品Id</th>
                        <th>物品名称</th>
                        <th>用户操作</th>
                        <th>时间</th>
                    </tr>
                </thead>
                <tbody>
                    <c:forEach items="${pageData.list}" var="one">
                        <tr>
                            <td>${one.logId}</td>
                            <td>${one.users.id}</td>
                            <td>${one.users.name}</td>
                            <td>${one.users.phone}</td>
                            <td>${one.users.email}</td>
                            <td>${one.users.address}</td>
                            <td>${one.goods.goodsId}</td>
                            <td>${one.goods.goodsName}</td>
                            <td>${one.operate}</td>
                            <td>${one.time}</td>
                        </tr>
                    </c:forEach>
                </tbody>
            </table>
            <div>
                <button class="btn btn-primary" onclick="firstPage()">首页</button>
                <button class="btn btn-primary" onclick="prevPage()">上一页</button>
                <button class="btn btn-primary" onclick="nextPage()">下一页</button>
                <button class="btn btn-primary" onclick="lastPage()">尾页</button>
                <span> 当前第${pageData.currentPage}页，共${pageData.totalPage}页，共${pageData.totalSize}条记录 </span>
            </div>
        </div>

        <script>
            var pageSize = ${pageData.pageSize};
            var pageNumber = ${pageData.currentPage};
            var totalPage = ${pageData.totalPage};
            function firstPage() {
                if(pageNumber != 1){
                    pageNumber = 1;
                    gotoPage();
                }
            }

            function prevPage() {
                if(pageNumber > 1){
                    pageNumber--;
                    gotoPage();
                }
            }

            function nextPage() {
                if(pageNumber < totalPage){
                    pageNumber ++;
                    gotoPage();
                }
            }

            function lastPage() {
                if(pageNumber != totalPage){
                    pageNumber = totalPage;
                    gotoPage();
                }
            }

            function gotoPage(){
                window.location.href = "${pageContext.request.contextPath}/log/getLogAll2?pageNumber=" +pageNumber;
            }
        </script>

    </body>
</html>
